/*   1:    */ package com.atomikos.diagnostics;
/*   2:    */ 
/*   3:    */ import java.io.IOException;
/*   4:    */ import java.io.PrintStream;
/*   5:    */ import java.text.DateFormat;
/*   6:    */ import java.text.SimpleDateFormat;
/*   7:    */ import java.util.Date;
/*   8:    */ 
/*   9:    */ public class PrintStreamConsole
/*  10:    */   implements Console
/*  11:    */ {
/*  12: 41 */   protected PrintStream printstream_ = null;
/*  13: 43 */   private int level_ = 1;
/*  14:    */   private DateFormat formatter_;
/*  15:    */   
/*  16:    */   public PrintStreamConsole(PrintStream printstream)
/*  17:    */   {
/*  18: 56 */     this.printstream_ = printstream;
/*  19: 57 */     this.formatter_ = new SimpleDateFormat("yy-MM-dd hh:mm:ss,SSS");
/*  20:    */   }
/*  21:    */   
/*  22:    */   private synchronized void printLineSuffix()
/*  23:    */     throws IOException
/*  24:    */   {
/*  25: 63 */     StringBuffer buf = new StringBuffer();
/*  26:    */     
/*  27:    */ 
/*  28: 66 */     Thread current = Thread.currentThread();
/*  29: 67 */     String tName = current.getName();
/*  30: 68 */     buf.append(this.formatter_.format(new Date()));
/*  31: 69 */     buf.append(" [" + tName + "]");
/*  32: 70 */     this.printstream_.print(buf.toString());
/*  33:    */   }
/*  34:    */   
/*  35:    */   public synchronized void println(String string)
/*  36:    */     throws IOException
/*  37:    */   {
/*  38: 80 */     printLineSuffix();
/*  39: 81 */     print(string);
/*  40: 82 */     this.printstream_.println();
/*  41:    */   }
/*  42:    */   
/*  43:    */   public synchronized void print(String string)
/*  44:    */     throws IOException
/*  45:    */   {
/*  46: 94 */     this.printstream_.print(string);
/*  47:    */   }
/*  48:    */   
/*  49:    */   public void close()
/*  50:    */     throws IOException
/*  51:    */   {
/*  52:105 */     this.printstream_.close();
/*  53:    */   }
/*  54:    */   
/*  55:    */   public void finalize()
/*  56:    */     throws Throwable
/*  57:    */   {
/*  58:    */     try
/*  59:    */     {
/*  60:111 */       close();
/*  61:    */     }
/*  62:    */     catch (Exception e) {}finally
/*  63:    */     {
/*  64:116 */       super.finalize();
/*  65:    */     }
/*  66:    */   }
/*  67:    */   
/*  68:    */   public void println(String string, int level)
/*  69:    */     throws IOException
/*  70:    */   {
/*  71:123 */     if (getLevel() >= level) {
/*  72:125 */       println(string);
/*  73:    */     }
/*  74:    */   }
/*  75:    */   
/*  76:    */   public void print(String string, int level)
/*  77:    */     throws IOException
/*  78:    */   {
/*  79:134 */     if (getLevel() >= level) {
/*  80:134 */       print(string);
/*  81:    */     }
/*  82:    */   }
/*  83:    */   
/*  84:    */   public void setLevel(int level)
/*  85:    */   {
/*  86:141 */     this.level_ = level;
/*  87:    */   }
/*  88:    */   
/*  89:    */   public int getLevel()
/*  90:    */   {
/*  91:147 */     return this.level_;
/*  92:    */   }
/*  93:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\atomikos-util\3.7.0\atomikos-util-3.7.0.jar
 * Qualified Name:     com.atomikos.diagnostics.PrintStreamConsole
 * JD-Core Version:    0.7.0.1
 */